package ar.Location.Helper;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTimeProvider {
	static SimpleDateFormat dateFormat = new SimpleDateFormat();
	static String longFortmat = "yyyy/MM/dd HH:mm:ss";
	static String shortFormat = "yyyy/MM/dd";
	static String yearFormat = "yyyy";
	static String monthFormat = "MM";
	static String dayFormat = "dd";
	static String strLongCurrentDate = null;
	static String strShortCurrentDate = null;
	static String strPreviousWeekDay = null;
	
	public static String getStringLongCurrentDate() {
		if(strLongCurrentDate == null) {
			Date currentDate = new Date();
			dateFormat.applyPattern(longFortmat);
			strLongCurrentDate = dateFormat.format(currentDate);
		}
		return strLongCurrentDate;
	}
	
	public static String getStringShortCurrentDate() {
		if(strShortCurrentDate == null) {
			Date currentDate = new Date();
			dateFormat.applyPattern(shortFormat);
			strLongCurrentDate = dateFormat.format(currentDate);
		}
		return strShortCurrentDate;
	}
	
	public static String getStringPreviousWeekDay() {
		if(strPreviousWeekDay == null) {
	        Calendar originalDate = Calendar.getInstance();
	        Calendar previousWeekDay = (Calendar) originalDate.clone();
	        previousWeekDay.add(Calendar.WEEK_OF_YEAR, -1);
	        Date date = previousWeekDay.getTime();
	        dateFormat.applyPattern(yearFormat);
	        String year = dateFormat.format(date);
	        dateFormat.applyPattern(monthFormat);
	        String month = dateFormat.format(date);
	        dateFormat.applyPattern(dayFormat);
	        String day = dateFormat.format(date);
			strPreviousWeekDay = year + "/" + month + "/" + day;
		}
		return strPreviousWeekDay;
	}
}
